package com.hk.mapper;

import com.hk.model.Admin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: zhe
 * @Date: 2021/6/8 15:20
 * @Statement:  管理员Mapper层接口
 */
public interface IAdminMapper extends IBaseMapper<Admin> {

    @Select("select * from admin where email = #{email} and password = #{password} and state = 0")
    Admin findByEmailAndPassword(Admin admin);

    @Select("select * from admin where email = #{email}")
    Admin findByEmail(String email);

    @Update("update admin set password=#{password},gmt_modified=#{gmtModified} where id = #{id}")
    int updatePassWord(Admin admin);


    @Override
    List<Admin> findAll(Admin admin);

    @Select("select count(1) from admin")
    @Override
    int count( Admin admin);

    @Select("select * from admin where id = #{id}")
    @Override
    Admin findById(Integer id);

    @Override
    int save(Admin admin);

    @Update("update admin set name=#{name},sex=#{sex},birthday=#{birthday},phone=#{phone},site=#{site},gmt_modified=#{gmtModified} where id = #{id}")
    @Override
    int update(Admin admin);

    @Delete("delete from admin where id = #{id}")
    @Override
    int delete(Integer id);
}
